package com.ruoyi.configuration.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.configuration.domain.MgSecondaryServiceType;
import com.ruoyi.configuration.service.IMgSecondaryServiceTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 二次服务类型Controller
 * 
 * @author ruoyi
 * @date 2024-01-16
 */
@RestController
@RequestMapping("/configuration/secondartservicetype")
public class MgSecondaryServiceTypeController extends BaseController
{
    @Autowired
    private IMgSecondaryServiceTypeService mgSecondaryServiceTypeService;

    /**
     * 查询二次服务类型列表
     */
    @PreAuthorize("@ss.hasPermi('configuration:secondartservicetype:list')")
    @GetMapping("/list")
    public TableDataInfo list(MgSecondaryServiceType mgSecondaryServiceType)
    {
        startPage();
        List<MgSecondaryServiceType> list = mgSecondaryServiceTypeService.selectMgSecondaryServiceTypeList(mgSecondaryServiceType);
        return getDataTable(list);
    }

    /**
     * 导出二次服务类型列表
     */
    @PreAuthorize("@ss.hasPermi('configuration:secondartservicetype:export')")
    @Log(title = "二次服务类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MgSecondaryServiceType mgSecondaryServiceType)
    {
        List<MgSecondaryServiceType> list = mgSecondaryServiceTypeService.selectMgSecondaryServiceTypeList(mgSecondaryServiceType);
        ExcelUtil<MgSecondaryServiceType> util = new ExcelUtil<MgSecondaryServiceType>(MgSecondaryServiceType.class);
        util.exportExcel(response, list, "二次服务类型数据");
    }

    /**
     * 获取二次服务类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('configuration:secondartservicetype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(mgSecondaryServiceTypeService.selectMgSecondaryServiceTypeById(id));
    }

    /**
     * 新增二次服务类型
     */
    @PreAuthorize("@ss.hasPermi('configuration:secondartservicetype:add')")
    @Log(title = "二次服务类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MgSecondaryServiceType mgSecondaryServiceType)
    {
        return toAjax(mgSecondaryServiceTypeService.insertMgSecondaryServiceType(mgSecondaryServiceType));
    }

    /**
     * 修改二次服务类型
     */
    @PreAuthorize("@ss.hasPermi('configuration:secondartservicetype:edit')")
    @Log(title = "二次服务类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MgSecondaryServiceType mgSecondaryServiceType)
    {
        return toAjax(mgSecondaryServiceTypeService.updateMgSecondaryServiceType(mgSecondaryServiceType));
    }

    /**
     * 删除二次服务类型
     */
    @PreAuthorize("@ss.hasPermi('configuration:secondartservicetype:remove')")
    @Log(title = "二次服务类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(mgSecondaryServiceTypeService.deleteMgSecondaryServiceTypeByIds(ids));
    }
}
